package com.icongyou.enterprise.talent_pool.controller;

import com.icongyou.enterprise.common.result.PageResult;
import com.icongyou.enterprise.common.result.Result;
import com.icongyou.enterprise.talent_pool.entity.vo.StudentTalentVO;
import com.icongyou.enterprise.talent_pool.service.StudentTalentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/home")
@RequiredArgsConstructor
public class HomePageController {

    private final StudentTalentService studentTalentService;

    /**
     * 分页获取学生人才信息列表
     */
    @GetMapping("/students")
    public Result<PageResult<StudentTalentVO>> getStudentTalents(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "size", defaultValue = "30") Integer size,
            @RequestParam(value = "teacherRecommended", required = false) Boolean teacherRecommended,
            @RequestParam(value = "coreTaskTop30", required = false) Boolean coreTaskTop30,
            @RequestParam(value = "hasHighPotential", required = false) Boolean hasHighPotential) {  // 新增参数

        try {
            PageResult<StudentTalentVO> result = studentTalentService.getStudentTalents(
                    page, size, teacherRecommended, coreTaskTop30, hasHighPotential);  // 传入新参数
            return Result.success(result);
        } catch (Exception e) {
            return Result.error("获取学生信息失败");
        }
    }
}